const bcrypt = require('bcrypt')//npm中加密以及加密验证插件，无法解密

const encrypt = async(password, saltTimes)=>{//进行加密
    const hash = await bcrypt.hash(password, saltTimes)
    return hash
}

//密码校验
const validate = async (password,hash) =>{//判断校验密码
    const result = await bcrypt.compare(password,hash)
    return result
}

module.exports = {
    validate,
    encrypt
}